/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.workforce.common.tags;

import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/**
 *
 * @author neo
 */
public class FieldBaseTag extends TagSupport {
    private static final long serialVersionUID = 2603193922657168385L;

    protected String sid;
    protected String style;
    protected String beanName;
    protected String name;
    protected String readOnly;
    protected String sClass;
    protected String label;
    protected String description;
    protected String validation;
    protected String onclick;
    protected String styleTooltip;
    protected String tooltipText;
    protected String onFocus;
    protected String onBlur;
    
    @Override
    public int doStartTag() throws JspException {
        return SKIP_BODY;
    }

    @Override
    public int doEndTag() throws JspException {
        return super.doEndTag();
    }

    public void setBeanName(String beanName) {
        this.beanName = beanName;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setStyle(String style) {
        this.style = style;
    }

    @Override
    public void setId(String sid) {
        this.sid = sid;
    }

    public void setReadOnly(String readOnly) {
        this.readOnly = readOnly;
    }

    public void setClass(String sclass) {
        this.sClass = sclass;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public void setValidation(String validation) {
        this.validation = validation;
    }

    public void setOnclick(String onclick) {
        this.onclick = onclick;
    }

    protected void beginTag() {
        JspWriter out = pageContext.getOut();
        StringBuilder s = new StringBuilder();
        try {
            s.append("<table border=\"0\"><tr>\n<td>\n<label>");
            if( label != null) {
            s.append(label);
            } else {
                s.append("");
            }
            s.append("</label>\n</td><td valign=\"bottom\">");
            out.print(s.toString());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    protected void endTag() {
        JspWriter out = pageContext.getOut();
        StringBuilder s = new StringBuilder();
        try {
            s.append("<td valign=\"middle\"><img src= \"imgs/info_16.png\" alt=\"info\" ");
            s.append("onmouseover=\"showInfo(this, event, 'info_" + sid + "')\" ></td>");
            s.append("<div id=\"info_" + sid + "\" ");
            if (styleTooltip == null) {
                s.append("class=\"styleTooltip_default\">");
            } else {
                s.append("class=\"");
                s.append(styleTooltip);
                s.append("\">");
            }
            if( tooltipText != null ) {
            s.append(tooltipText);
            } else {
                s.append("Description for "+ sid + ".");
            }
            s.append("</div></td></tr></table>");
            out.print(s.toString());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public void setStyleTooltip(String styleTooltip) {
        this.styleTooltip = styleTooltip;
    }

    public void setTooltipText(String tooltipText) {
        this.tooltipText = tooltipText;
    }

    public String getOnBlur() {
        return onBlur;
    }

    public void setOnBlur(String onBlur) {
        this.onBlur = onBlur;
    }

    public String getOnFocus() {
        return onFocus;
    }

    public void setOnFocus(String onFocus) {
        this.onFocus = onFocus;
    }

    
}
